<?php
/**
 * 本类不负责给键加前缀
 * 
 * @author Dvaknheo
 * @category  
 * @package DnToolkit
 */
class DnCache //implements IDnCache
{
	public $config=array();
	
	public static $default_cache_class = 'DnCacheNull';
	public static function GetInstance() {
		return self :: Self();
	}
	public static function Self($obj = null) {
		$classname = self :: $default_cache_class;

		$mustbe_childclass = false;
		$key = 'Dvaknheo_' . $classname;
		if ($obj) {
			if ($mustbe_childclass && !is_a($obj, $classname)) {
				$GLOBALS[$key] = $GLOBALS[$key] ? $GLOBALS[$key] : new $classname ($obj);
			} else {
				$GLOBALS[$key] = $obj;
			}
		} else
			if (empty($GLOBALS[$key])) {
				$GLOBALS[$key] = new $classname ();
			}
		return $GLOBALS[$key];
	}
	public function __construct($config=array()) {
		$this->config=array_merge($this->config,$config);
		return;
	}
	///////////////////////////////////////////////////////////////////////////
	public function _get($key) {
		throw new DnException("Implement Me!");
	}
	public function _set($key, $value, $expire = 0) {
		throw new DnException("Implement Me!");
	}
	public function _delete($key) {
		throw new DnException("Implement Me!");
	}
	///////////////////////////////////////////////////////////////////////////
	public static function Set($keys, $value, $expire = 0) {
		return self :: Self()->_set($keys, $value, $expire);
	}
	public static function Get($key) {
		return self :: Self()->_get($key);
	}

	public static function Delete($key) {
		return self :: Self()->_delete($key);
	}
}